package com.sgb.kjwl.view.ui.adapter.packers;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.link.view.adapter.ItemViewHolder;
import com.sgb.link.view.adapter.PageRecycleAdapter;

import java.util.List;


public class TeamMainMenuAdapter extends PageRecycleAdapter<AddressEntity> {
    public TeamMainMenuAdapter(Context context, List<AddressEntity> datas) {
        super(context, R.layout.item_logistics_menu, datas);
    }

    RequestOptions options = new RequestOptions().placeholder(R.drawable.bg_transport_menu)//图片加载出来前，显示的图片
            .fallback(R.drawable.bg_transport_menu) //url为空的时候,显示的图片
            .error(R.drawable.bg_transport_menu);//图片加载失败后，显示的图片

    @Override
    public void convert(ItemViewHolder holder, AddressEntity menuEntity) {
        ImageView tv = holder.itemView.findViewById(R.id.iv_kingKongDiagram);
        if(menuEntity.getIconResourceID()!=0){
            Glide.with(context).load(menuEntity.getIconResourceID()).apply(options).into(tv);
        }else {
            Glide.with(context).load(menuEntity.getIconUrl()).apply(options).into(tv);
        }
    }
}
